package net.sf.midollo.net.io;

import net.sf.midollo.io.IOStream;
import net.sf.midollo.io.IOStreamFactory;
import net.sf.midollo.net.NetUtils;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpIOStreamFactory implements IOStreamFactory {

	protected final URL url;
	protected final String method;

	public HttpIOStreamFactory(URL url, String method) {
		this.url = url;
		this.method = method;
	}

	public IOStream open() throws IOException {
		HttpURLConnection httpURLConnection = NetUtils.getHttpConnection(this.url, this.method);
		return new HttpIOStream(httpURLConnection);
	}
}
